#!/usr/bin/env python

import nltk
from nltk.corpus import brown
from nltk import FreqDist

brown_tagged_sents = brown.tagged_sents(categories='news')
brown_sents = brown.sents(categories='news')
size = int (len(brown_tagged_sents) * 0.9)
train_data = brown_tagged_sents[:size]
test_data = brown_tagged_sents[size:]

t0 = nltk.DefaultTagger('NN')
t1 = nltk.UnigramTagger(train_data,backoff=t0)
t2 = nltk.BigramTagger(train_data,backoff=t1)
t3 = nltk.TrigramTagger(train_data,backoff=t2)

print 'UnigramTagger, ',t1.evaluate(test_data)
print 'BigramTagger, ',t2.evaluate(test_data)
print 'TrigramTagger, ',t3.evaluate(test_data)
